package com.qf.hospital.mapper;

import com.qf.hospital.entity.Pharmacy;
import com.qf.hospital.entity.PharmacyExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface PharmacyMapper {
    long countByExample(PharmacyExample example);

    int deleteByExample(PharmacyExample example);

    int deleteByPrimaryKey(Integer pharmacyId);

    int insert(Pharmacy record);

    int insertSelective(Pharmacy record);

    List<Pharmacy> selectByExample(PharmacyExample example);

    Pharmacy selectByPrimaryKey(Integer pharmacyId);

    int updateByExampleSelective(@Param("record") Pharmacy record, @Param("example") PharmacyExample example);

    int updateByExample(@Param("record") Pharmacy record, @Param("example") PharmacyExample example);

    int updateByPrimaryKeySelective(Pharmacy record);

    int updateByPrimaryKey(Pharmacy record);

    List<Pharmacy> findPharmacyInfos(@Param("drugname") String drugname);

    @Select("select drug_store_num from pharmacy where reportId = #{reportId} and pharmacy_name = #{durgname}")
    int findCountByNameAndId(@Param("reportId") Integer reportId,@Param("durgname") String durgname);

    @Update("update pharmacy set drug_num = drug_num + #{durgnum}")
    void updateDrunNum(@Param("durgnum") Integer durgnum);

    @Select("select repice_price from cashier where drug_name = #{durgname} and report_id = #{id}")
    Double findPriceByName(String durgname);
}